#include <bits/stdc++.h>
using namespace std;
class Solution
{
  public:
    // // 检查字符串是否以元音开头和结尾
    // bool isVowelString(const std::string &word)
    // {
    //     std::unordered_set<char> vowels = {'a', 'e', 'i', 'o', 'u'};
    //     char first = word[0];
    //     char last = word.back();
    //     return vowels.count(first) > 0 && vowels.count(last) > 0;
    // }
    bool check(string &now)
    {
        char first = now[0];
        char end = now.back();
        string Finding = "aeiou";
        // 查找当前字符串的首尾字符是否存在元音aeiou中
        return ((Finding.find(first) != string::npos) &&
                (Finding.find(end) != string::npos));
    }

    // 构建前缀和
    vector<int> Calculate(vector<string> &words)
    {
        int n = words.size();
        vector<int> sum(n + 1, 0);
        for (int i = 0; i < n; i++)
        {
            int now = check(words[i]) ? 1 : 0;
            sum[i + 1] = sum[i] + now;
        }
        return sum;
    }
    vector<int> vowelStrings(vector<string> &words,
                             vector<vector<int>> &queries)
    {
        vector<int> sum = Calculate(words);
        vector<int> ans;
        for (auto &t : queries)
        {
            int left = t[0];
            int right = t[t.size() - 1];
            ans.push_back(sum[right + 1] - sum[left]);
        }
        return ans;
    }
};